home *** CD-ROM | disk | FTP | other *** search
- /*
- e screen editor
-
- (C) G. Nigel Gilbert, MICROLOGY, 1981
-
- August-December 1981
-
- FILE: etvi
-
- FUNCTIONS: terminit,terminal,gotoxy,deleteline,linedelete,delpage,
- insertline,begdim,enddim,keytranslate,displayhelp
-
- PURPOSE: terminal dependent screen control functions
-
- NOTE this file is specific to the TeleVideo range of terminals.
- It may be used as a model for others
- */
-
- #include "e.h"
-
- /* control key codes, here for convenience in defining terminal sequences*/
-
- #define CTRLA 0x01 /* SOH */
- #define CTRLB 0x02 /* STX */
- #define CTRLC 0x03 /* ETX */
- #define CTRLD 0x04 /* EOT */
- #define CTRLE 0x05 /* ENQ */
- #define CTRLF 0x06 /* ACK */
- #define CTRLG 0x07 /* BEL */
- #define CTRLH 0x08 /* BS */
- #define CTRLI 0x09 /* HT */
- #define CTRLJ 0x0a /* LF */
- #define CTRLK 0x0b /* VT */
- #define CTRLL 0x0c /* FF */
- #define CTRLM 0x0d /* CR */
- #define CTRLN 0x0e /* SO */
- #define CTRLO 0x0f /* SI */
- #define CTRLP 0x10 /* DLE */
- #define CTRLQ 0x11 /* DC1 */
- #define CTRLR 0x12 /* DC2 */
- #define CTRLS 0x13 /* DC3 */
- #define CTRLT 0x14 /* DC4 */
- #define CTRLU 0x15 /* NAK */
- #define CTRLV 0x16 /* SYN */
- #define CTRLW 0x17 /* ETB */
- #define CTRLX 0x18 /* CAN */
- #define CTRLY 0x19 /* EM */
- #define CTRLZ 0x1a /* SUB */
- #define SOH 0x01
- #define STX 0x02
- #define ETX 0x03
- #define EOT 0x04
- #define ENQ 0x05
- #define ACK 0x06
- #define BEL 0x07
- #define BS 0x08
- #define HT 0x09
- #define LF 0x0a
- #define VT 0x0b
- #define FF 0x0c
- #define RETURN 0x0d
- #define SO 0x0e
- #define SI 0x0f
- #define DLE 0x10
- #define DC1 0x11
- #define DC2 0x12
- #define DC3 0x13
- #define DC4 0x14
- #define NAK 0x15
- #define SYN 0x16
- #define ETB 0x17
- #define CAN 0x18
- #define EM 0x19
- #define SUB 0x1a
- #define ESC 0x1b
- #define FS 0x1c
- #define GS 0x1d
- #define RS 0x1e
- #define US 0x1f
- #define DEL 0x7f
-
- /*-------------------------OUTPUT TO SCREEN---------------------------*/
-
-
-
- /* screen control characters for TVI912C, ADM31 */
- #define BEGINDIM ')'
- #define ENDDIM '('
- #define CRSADDR '='
- #define INSLINE 'E'
- #define DELLINE 'T' /*delete to spaces*/
- #define LINDEL 'R' /*delete and close up*/
- #define PAGEDEL 'Y'
-
- terminit() /*initialise terminal. Called once before any output to
- to terminal is performed */
- {
- }
-
- termfini() /*restore terminal to 'normal' state. Called once before
- program exits */
- {
- }
-
- terminal() /*display name of terminal*/
- {
- puts("|for TVI-912/920");
- }
-
- gotoxy(x,y) /*move cursor to column x, line y {top left is (0,0) */
- int x,y;
- {
- putch(ESC);
- putch(CRSADDR);
- putch(y+32);
- putch(x+32);
- }
-
- deleteline(x,y) /*clear to spaces all characters on line y from column x
- to the right edge of the screen, inclusive.
- Leave cursor on left most blank */
- int x, y;
- {
- gotoxy(x,y);
- putch(ESC);
- putch(DELLINE);
- gotoxy(x,y);
-
- }
-
- linedelete(y) /*delete the line y. All following lines move up one.
- Leave cursor at start of line y */
- int y;
- {
- gotoxy(0,y);
- putch(ESC);
- putch(LINDEL);
- }
-
- delpage(y) /*clear to spaces line y and all following lines. Leave
- cursor at the start of line y */
- int y;
- {
- gotoxy(0,y);
- putch(ESC);
- putch(PAGEDEL);
- }
-
- insertline() /*move all lines below line on which cursor is, down one,
- losing last line. New cursor line is blank, with
- cursor at start of line */
- {
- putch(ESC);
- putch(INSLINE);
- }
-
- begdim() /*display all subsequent characters at half intensity*/
- {
- putch(ESC);
- putch(BEGINDIM);
- }
-
- enddim() /* display all subsequent characters at full intensity */
- {
- putch(ESC);
- putch(ENDDIM);
- }
-
-
- /*----------------------INPUT FROM KEYBOARD-----------------------------*/
-
-
- keytranslate() /*defines the terminal key codes which perform
- the editor commands */
- {
- /* each tran[xxxx]= should be set to the code emitted by the terminal
- key which will perform the indicated action. The recommended (control)
- key assignments are shown in round brackets.
- Some terminals precede their codes by a lead-in character
- (eg the Hazeltine uses the tilde). This char should be assigned to
- tran[LEADIN]. If there is no lead-in character, set tran[LEADIN] to zero.
- 'e' will ignore the leadin character if tran[LEADIN] is non-zero,
- but will set the parity bit on the next character. All other chars from the
- keyboard will already have any parity bits removed as they are read in. Thus
- codes with lead-ins should be entered in the table below as code+0x80, or
- more clearly, as code+PARBIT.
- For example, suppose that one is coding the Hazeltine 1420, which
- generates a tilde,^L (0x0d) sequence when the cursor up key is pressd. To
- recognise this sequence, set tran[LEADIN] to tilde (0x7e) and set
- tran[UPKEY] to 0x0d+PARBIT.
- */
-
- tran[LEADIN]=0; /*lead-in character, 0 if not used*/
- tran[DOWNKEY]= CTRLJ; /*cursor down */
- tran[UPKEY]= CTRLK; /*cursor up*/
- tran[LEFTKEY]= CTRLH; /*cursor left*/
- tran[RIGHTKEY]= CTRLL; /*cursor right*/
- tran[RIGHTWKEY]= CTRLD; /*cursor right one word (D) */
- tran[LEFTWKEY]= CTRLS; /*cursor left one word (S) */
- tran[EOLKEY]= CTRLE; /*cursor to end of line (E) */
- tran[BOLKEY]= CTRLB; /*cursor to beginning of line (B) */
- tran[UPPAGE]= CTRLW; /*scroll up a page (W) */
- tran[DOWNPAGE]= CTRLZ; /*scroll down a page (Z) */
- tran[BOFKEY]= CTRLU; /*cursor to beginning of file (U) */
- tran[HOMEKEY]= RS; /*cursor to end of file (HOME) */
- tran[DELLEFT]= DEL; /*delete char to left of cursor (DEL) */
- tran[DELRIGHT]= CTRLG; /*delete char under cursor (G) */
- tran[DELLNKEY]= CTRLY; /*delete cursor line (Y) */
- tran[DELWDKEY]= CTRLT; /*delete word to right of cursor (T) */
- tran[JUMPKEY]= CTRLX; /*jump to (X) */
- tran[CRSTILL]= CTRLN; /*insert newline after cursor (N) */
- tran[QUITKEY]= CTRLQ; /*quit (Q) */
- tran[ENVIRKEY]= CTRLC; /*edit and file context (C) */
- tran[FINDKEY]= CTRLF; /*find (F) */
- tran[ALTERKEY]= CTRLA; /*alter (A) */
- tran[BLOCKKEY]= CTRLO; /*block operations (O) */
- tran[RDFILEKEY]= CTRLP; /*read a file (P) */
- tran[REPKEY]= CTRLR; /*repeat last find/alter (R) */
- tran[HELPKEY]= CTRLV; /*display help menu (V) */
- tran[UNDOKEY]= FS; /*restore unedited line (\) */
- tran[TAB]= CTRLI; /*tab (I) */
- tran[RETRIEVE]= CTRLR; /*retrieve (R)*/
- tran[CR]= CTRLM; /*return*/
- tran[ESCKEY]=ESC; /*escape, the magic key (ESC)*/
- }
-
- /*-------------------------------HELP MENU-------------------------------*/
-
-
- displayhelp() /*display the help menu. There must be (helplines-1)
- lines of menu here (see terminal function,above) */
- {
- puts("CURSOR: ^B|=beginning of line| ^E|=end of line| ^S|=left word| ^D|=right word\n");
- puts("MOVE: ^W|=up a screen| ^Z|=down a screen| ^U|=top, |HOME|=bottom of file\n");
- puts("DELETE: DEL|=char left| ^G|=char right| ^T|=word| ^Y|=line| ^\\|=undo\n");
- puts(" ^F|=find| ^A|=alter| ^R|=repeat| ^V|=view menu\n");
- puts(" ^ ^N|=insert a new line| ^X|=jump to line| ^P|=read file| ^Q|=quit,save file\n");
- puts(" <- -> ^C|=edit,file context| ^O|=write,print,shift,move,copy,or delete block\n");
- puts("---v------------------------------------------------------------------------");
- }
-
-
- /*---------------------------------END---------------------------------------*/
- *scroll down a page (Z) */
- tran[BOFKEY]= CTRLU; /*cursor to beginning of file (U) */
- tran[H